package com.heima.wemedia.controller.v1;

import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.common.dtos.WmStatisticsPageDto;
import com.heima.wemedia.service.WmStatisticsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.websocket.server.PathParam;
import java.util.Date;

@RestController
@Slf4j
@Api("图文数据模块")
@RequestMapping("/api/v1/statistics")
public class WmStatisticsController {
    @Autowired
    private WmStatisticsService wmStatisticsService;

    /**
     * 数量统计
     *
     * @return
     */
    @ApiOperation("根据时间进行查询图文数据")
    @GetMapping("/newsDimension")
    public ResponseResult newDimension(
            @RequestParam(value = "beginDate", required = false) String beginDate,
            @RequestParam(value = "endDate", required = false) String endDate
    ) {
        log.info("根据时间查询数据，{},{}", beginDate, endDate);
        return wmStatisticsService.newDimension(beginDate, endDate);
    }

    /**
     * 分页查询
     *
     * @param
     * @return
     */
    @GetMapping("newsPage")
    @ApiOperation("分页查询")
    public ResponseResult newPage(@RequestParam(value = "beginDate", required = false) String beginDate,
                                  @RequestParam(value = "endDate", required = false) String endDate,
                                  @RequestParam(value = "page", required = false) Integer page,
                                  @RequestParam(value = "size", required = false) Integer size) {
        log.info("图文数据的分页查询：{}，{}，{}，{}", beginDate, endDate, page, size);
        return wmStatisticsService.newPage(beginDate, endDate, page, size);
    }
}
